import http from '@http/http'
export const getJoinActivity = (uid, errMsg) => http.GET(`/api/activity/getJoinActivity?uid=${uid}`, {}, errMsg)
export const queryIfJoin = (uid, aid, errMsg) => http.GET(`/api/activity/queryIfJoin?uid=${uid}&aid=${aid}`, {}, errMsg)
export const getNotJoinActivity = (uid, errMsg) => http.GET(`/api/activity/getNotJoinActivity?uid=${uid}`, {}, errMsg)
export const getReleaseActivity = (uid, errMsg) => http.GET(`/api/activity/getReleaseActivity?uid=${uid}`, {}, errMsg)
export const Join = (uid, aid, essMsg) => http.GET(`/api/activity/Join?uid=${uid}&aid=${aid}`, {}, essMsg)
export const ExitActivity = (uid, aid, essMsg) => http.GET(`/api/activity/ExitActivity?uid=${uid}&aid=${aid}`, {}, essMsg)
export const getDetail = (aid, essMsg) => http.GET(`/api/activity/getDetail?aid=${aid}`, {}, essMsg)
export const queryIfRelease = (aid, errMsg) => http.GET(`/api/activity/queryIfRelease?aid=${aid}`, {}, errMsg)
export const updateActivityStatus = (aid, errMsg) => http.GET(`/api/activity/updateActivityStatus?aid=${aid}`, {}, errMsg)
export const updateActivityStatus1 = (aid, errMsg) => http.GET(`/api/activity/updateActivityStatus1?aid=${aid}`, {}, errMsg)
export const updateActivityStatus2 = (aid, errMsg) => http.GET(`/api/activity/updateActivityStatus2?aid=${aid}`, {}, errMsg)
export const deleteActivity = (aid, errMsg) => http.GET(`/api/activity/deleteActivity?aid=${aid}`, {}, errMsg)
export const createActivity = (activity) => http.POST(`/api/activity/createActivity`, activity)
export const queryCheckStatus = (uid, aid) => http.GET(`/api/activity/queryCheckStatus?uid=${uid}&aid=${aid}`)
export const queryActivityName = (activityName) => http.GET(`/api/activity/queryIdByName?name=${activityName}`)
export const insertCheck = (uid, aid) => http.GET(`/api/check/insertCheck?uid=${uid}&aid=${aid}`)
export const getActivityByUid = (uid) => http.GET(`/api/activity/getActivityByUid?uid=${uid}`)
export const insertActivityAndSchool = (postDate) => http.POST(`/api/activity/insertActivityAndSchool`, postDate)
export const getAllActivity = () => http.GET(`api/activity/getAllActivity`)
export const activityRelease = (rule, sid, errMsg) => {
  const filteredRule = {}
  Object.entries(rule).forEach(([key, value]) => {
    if (value !== null && value !== undefined && value !== '') {
      filteredRule[key] = value
    }
  })
  const queryString = Object.entries(filteredRule)
    .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
    .join('&')
  const url = `/api/activity/activityRelease?${queryString}&sid=${encodeURIComponent(sid)}`
  return http.GET(url, {}, errMsg)
}
